package ph.com.gs3.formalistics.model.dao;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class ConfigDAO extends DataAccessObject {

	public static final String CONFIG_PREFERENCES_FILE = "_CONFIG";

	private static final String LAST_FORMS_UPDATE = "last_forms_update";
	private static final String LAST_DOCUMENTS_UPDATE = "last_documents_update";

	private SharedPreferences preferences;

	public ConfigDAO(Context context) {
		super(context);
		preferences = context.getSharedPreferences(CONFIG_PREFERENCES_FILE, Context.MODE_PRIVATE);
	}

	public String getLastFormsUpdate() {
		return preferences.getString(LAST_FORMS_UPDATE, null);
	}

	public void setLastFormsUpdate(String formsUpdateDate) {

		Editor edit = preferences.edit();
		edit.putString(LAST_FORMS_UPDATE, formsUpdateDate);
		edit.apply();

	}

	public String getLastDocumentsUpdate() {
		return preferences.getString(LAST_DOCUMENTS_UPDATE, null);
	}

	public void setLastDocumentsUpdate(String documentsUpdateDate) {

		Editor edit = preferences.edit();
		edit.putString(LAST_FORMS_UPDATE, documentsUpdateDate);
		edit.apply();

	}

}
